home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 3180 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.7 KB

  1. Path: news.eclipse.net!usenet
  2. From: meritech@eclipse.net
  3. Newsgroups: comp.lang.c
  4. Subject: Re: performance of fread
  5. Date: 26 Jan 1996 17:08:42 GMT
  6. Message-ID: <4eb1qq$ove@lunar.eclipse.net>
  7. References: <4eaecp$m5a@zeus.rbi.informatik.uni-frankfurt.de>
  8. Reply-To: meritech@eclipse.net
  9. NNTP-Posting-Host: so_69.eclipse.net
  10. X-Newsreader: IBM NewsReader/2 v1.2
  11.  
  12. >My question: How time consuming is the overhead of calling fread reading from 
  13. >a large buffer compared to a for( ) loop which takes his data from a memory 
  14. >block which was filled by a single call of fread. 
  15.  
  16. Well.  I'll tell you.  If this helps.  I had the same problem.  I had to read in an index
  17. to a database ( C type structures ), that had over 1000 elements to the index.
  18. Performing 1000 freads would take way to long, so we swapped out the un-used
  19. section of memory at the time into XMS, freeing up about 50k of DOS memory in
  20. the app, allocated the 40k needed to hold the data, and performed one big fread
  21. into the 40k heap, then, memcpy'd the data into the structure pointer (already allo-
  22. cated for the 40k), free'd up the 40k buffer, closed the file and reloaded the data
  23. from XMS into it's right locations.
  24.  
  25. The optimized process takes about 2 seconds less than the origional code, and the
  26. profiler shows an almost 25% reduction in code execution for that function, freeing
  27. up much needed processor time.
  28.  
  29. The main problem here, is when we attempt to load the 120k record base into xms,
  30. that damm near takes forever, so we parse load it, 20k initial, when they get 1/2 way
  31. through the data view, we quickly load another 20k, you notice this on the pgu-pgd
  32. combo's, but just regular scrolling or searching is fine.
  33.  
  34. Hope that helps.
  35.  
  36.